﻿<phone:PhoneApplicationPage 
    x:Class="Coevery.PhoneApp.QuoteDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:myConverter="clr-namespace:Coevery.PhoneApp.Convert"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False" BackKeyPress="PhoneApplicationPage_BackKeyPress">

    <phone:PhoneApplicationPage.Resources>
        <myConverter:ColorConverter x:Name="ColorConverter"></myConverter:ColorConverter>
        <myConverter:MetadataConverter x:Name="MetadataConverter"></myConverter:MetadataConverter>
        <DataTemplate x:Name="QuoteDetailTemplate">
            <StackPanel Orientation="Vertical" Width="450">
                <StackPanel Margin="0 5 0 0" Orientation="Horizontal">
                    <Image Source="Images/customer.png"></Image>
                    <TextBlock DataContext="{Binding Owner}" Text="{Binding FullName}" Foreground="Black" Margin="5 0 0 0" FontSize="26" TextWrapping="Wrap"></TextBlock>
                </StackPanel>
                <StackPanel Orientation="Vertical" Margin="0 5 0 0">
                    <TextBlock Text="{Binding Name}" Foreground="Black" HorizontalAlignment="Left" TextWrapping="Wrap"></TextBlock>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
                    <StackPanel Orientation="Vertical" Width="225">
                        <TextBlock Text="Customer" Foreground="#0597d2" Width="110" HorizontalAlignment="Left"></TextBlock>
                        <TextBlock DataContext="{Binding Customer}" Text="{Binding Name}" Foreground="Black" HorizontalAlignment="Left"></TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Width="225">
                        <TextBlock Text="Business Opportunity" Foreground="#0597d2" Width="200" HorizontalAlignment="Left"></TextBlock>
                        <TextBlock DataContext="{Binding Opportunity}" Text="{Binding Name}" Foreground="Black" HorizontalAlignment="Left"></TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
                    <StackPanel Orientation="Vertical" Width="225">
                        <TextBlock Text="TotalAmount" Foreground="#0597d2" Width="110" HorizontalAlignment="Left"></TextBlock>
                        <TextBlock Text="{ Binding TotalAmount}" Foreground="Black" HorizontalAlignment="Left"></TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Width="225">
                        <TextBlock Text="Stage" Foreground="#0597d2" Width="200" HorizontalAlignment="Left"></TextBlock>
                        <TextBlock Text="{Binding StatusCode, Converter={StaticResource MetadataConverter}, ConverterParameter=quote_stagecode}" Foreground="Black" HorizontalAlignment="Left"></TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
                    <StackPanel Orientation="Vertical" Width="225">
                        <TextBlock Text="End Date" Foreground="#0597d2" Width="110" HorizontalAlignment="Left"></TextBlock>
                        <TextBlock Text="{Binding ExpiresOn}" Foreground="Black" HorizontalAlignment="Left"></TextBlock>
                    </StackPanel>                    
                    <StackPanel Orientation="Vertical" Width="225">
                        <TextBlock Text="Update Date" Foreground="#0597d2" Width="200" HorizontalAlignment="Left"></TextBlock>
                        <TextBlock Text="{Binding ModifiedOn}" Foreground="Black" HorizontalAlignment="Left"></TextBlock>
                    </StackPanel>
                </StackPanel>
                    <StackPanel Margin="0 10 0 0">
                        <TextBlock Text="Description" Foreground="#0597d2" HorizontalAlignment="Left" Width="110"></TextBlock>
                        <TextBlock Text="{Binding Description}" Foreground="Black" Margin="0,5" TextWrapping="Wrap" VerticalAlignment="Top"></TextBlock>
                </StackPanel>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Name="QuoteCommentsTemplate">
            <Border Margin="0 10 0 0">
                <StackPanel Width="450" Margin="5 5 5 5 " VerticalAlignment="Top">
                    <StackPanel Orientation="Horizontal">
                        <StackPanel Width="225" Orientation="Horizontal">
                            <Image Source="Images/customer.png" Margin="5 0 0 0"></Image>
                            <TextBlock DataContext="{Binding ModifiedBy}" Text="{Binding FullName}" Margin="5 0 0 0" Foreground="Black" TextWrapping="Wrap"></TextBlock>
                        </StackPanel>
                        <StackPanel Width="225">
                            <TextBlock Text="{Binding ModifiedOn}" Foreground="#aeb3b6" TextAlignment="Right"></TextBlock>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel  Margin="0 5 0 0">
                    <TextBlock Text="{Binding Subject}" Margin="27 0 0 0" FontSize="28"   TextWrapping="Wrap" Foreground="Black" ></TextBlock>
                </StackPanel>
                <StackPanel Margin="0 5 0 0">
                    <TextBlock Text="{Binding NoteText}" Margin="27 0 0 0"  TextWrapping="Wrap" Foreground="Black"></TextBlock>
                </StackPanel>
                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu>
                        <toolkit:MenuItem Header="Edit" Click="EditComment_Click"/>
                        <toolkit:MenuItem Header="Delete" Click="DeleteComment_Click"/>
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>
                </StackPanel>
            </Border>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>
    
    <Grid x:Name="LayoutRoot" Background="White">
        <controls:Pivot x:Name="ctlPanorama" Foreground="#0597d2">
            <controls:PivotItem x:Name="PanDetail" Header="Detail">
                <ListBox x:Name="detailListBox" ItemTemplate="{StaticResource QuoteDetailTemplate}" Margin="0 0 -12 0" ItemsSource="{Binding Quotes}"></ListBox>
            </controls:PivotItem>
            <controls:PivotItem x:Name="PanComments" Header="Comments">
                <ListBox x:Name="commentsListBox" ItemsSource="{Binding Notes}" ItemTemplate="{StaticResource QuoteCommentsTemplate}" Margin="0 0 -12 0">
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" BackgroundColor="#0066cc" Opacity="10">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar.feature.home.rest.png" Text="Home"  Click="Home_Click"></shell:ApplicationBarIconButton>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar.add.rest.png" Text="Add Comment"  Click="AddComments_Click"></shell:ApplicationBarIconButton>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar.refresh.rest.png" Text="Refresh" Click="Refresh_Click" ></shell:ApplicationBarIconButton>

            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Convert to Delivered" Click="ApplicationBarMenuItem_Click"/>
                <shell:ApplicationBarMenuItem Text="Convert to Closed Accepted" Click="ApplicationBarMenuItem_Click"/>
                <shell:ApplicationBarMenuItem Text="Convert to Re-quote" Click="ApplicationBarMenuItem_Click"/>
                <shell:ApplicationBarMenuItem Text="Convert to Closed Dead" Click="ApplicationBarMenuItem_Click"/>
                <shell:ApplicationBarMenuItem Text="Convert to Closed Lost" Click="ApplicationBarMenuItem_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
        
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
